package main

import (
	"fmt"
	"jingzhoulianxin/model"
	"time"
)

func main() {

	for {
		fmt.Println("程序正在运行...")
		// 6-9 , 5-7
		time.Sleep(10 * time.Second)
		nowTime := time.Now()
		hour := nowTime.Hour()

		if hour >= 11 && hour <= 13{
			InsertData()
		}else if hour >= 0 && hour <=5{
			time.Sleep(time.Hour)
		}else if hour >= 17 && hour <= 19{
			InsertData()
		}else{
			time.Sleep(4 * 60 * time.Second)
			InsertData()
		}
	}
}

func InsertData()  {
	_, accountFlow := model.GetMaxFlowId()

	fmt.Println(accountFlow.FlowId)

	err, list :=model.AccountFlowList(accountFlow.FlowId)

	if err != nil{
		fmt.Println(err)
	}

	if len(list) > 0{
		model.InsertData(list)
	}
}